import Vue from 'vue'
import Vuex from "vuex"

Vue.use(Vuex)

const store = new Vuex.Store({
    //全局变量
    state: {
        user:JSON.parse(localStorage.getItem('user')) ,
        articleList: undefined , //处理浏览器回退问题，待定
        domain: 'http://seekerservice.usts.top/api'
    },
    getters: {
        // getUser (state) {
        //     return 
        // }
    },
    mutations: {
        login (state,payload) {
            state.user = payload
        },
        logout (state) {
            state.user = undefined
        },
        setArticleList (state,list) {
            state.articleList = list
        },
        concatArticleList (state,list) {
            state.articleList = state.concat(list)
        },
        clearArticleList (state) {
            state.articleList = undefined
        }
    },
    actions : {
        // login (context,payload) {
        //     context.commit('login',payload)
        // },
        // logout (context) {
        //     context.commit('logout')
        // }
    }
})

export default store